<template>
  <div>
    <ul>
      <li v-for="(item, index) in list" :key="index" class="sb">
        <input type="checkbox" @click.stop="change(index, item, $event)" />
        <span>{{ item }}</span>
      </li>
    </ul>
    <br />
    <ul>
      <li v-for="(item, index) in arr" :key="index">{{ item }}</li>
    </ul>
  </div>
</template>

<script>
export default {
  data() {
    return {
      list: ["科幻", "喜剧", "动漫", "冒险", "科技", "军事", "娱乐", "奇闻"],
      arr: [],
    };
  },
  computed: {},
  watch: {},
  created() {},
  methods: {
    change(index, s, e) {
      e.target.checked
        ? this.arr.push(this.list[index])
        : this.arr.splice(
            this.arr.findIndex((item) => item === s),
            1
          );
    },
  },
};
</script>

<style scoped>
.sb {
  list-style: none;
  float: left;
}
</style>
